package com.telit.android.service.impl;

import com.telit.android.dao.CommAppVersionDao;
import com.telit.android.entity.AppVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;


/**
 * @Auther amy
 * @Describe app版本信息业务层
 */
@Service
public class AppVersionService {

    @Autowired
    private CommAppVersionDao appVersionDao;

    /**
     * 查询最新版本的app信息
     * @return
     */
    public AppVersion selectLatestVersion(String type){
        List<AppVersion> appVersionList = appVersionDao.selectAppByType(type);
        if(!CollectionUtils.isEmpty(appVersionList)){
            // 排序,集合不为空选取第一个数据
            AppVersion appVersion = appVersionList.get(0);
            if(appVersion != null) {
                //TODO:v1.1.0 图片预览
//               appVersion.setLinkUrl(MinioUtils.previewImg(appVersion.getLinkUrl()));
            }
            return appVersionList.get(0);
        }
        return null;
    }

}
